const router = require('koa-router')();
const getFeedSubmissionResult = require('../../app/mws/feeds/GetFeedSubmissionResult');

router.prefix('/api/v1/feeds');

router.get('/', function (ctx, next) {
  ctx.body = 'this is a users response!'
});

router.get('/submissions/result/:submissionid', async (ctx, next) =>{
    let sellerId = ctx.headers.sellerid;
    let mwsAuthToken = ctx.headers.mwsauthtoken;

    let submissionId = ctx.params.submissionid;

    try {
        let json = await getFeedSubmissionResult.getFeedSubmissionResult(sellerId, mwsAuthToken, submissionId);
        console.log(json);
        ctx.response.status = 200;
        ctx.response.body = {
            data: json,
        };
    } catch (error) {
        ctx.response.status = 500;
        ctx.response.body = {
            data: error,
        };
    }
});

module.exports = router;
